}
dom->domid = domid;
-
dom->conspath = xs_get_domain_path(xs, dom->domid);
- if (dom->conspath == NULL)
- goto out;
s = realloc(dom->conspath, strlen(dom->conspath) +
strlen("/console") + 1);
if (s == NULL)
}
#define xspy_get_domain_path_doc "\n" \
- "Return store path of domain.\n" \
+ "Return store path of domain, whether or not the domain exists.\n" \
" domid [int]: domain id\n" \
"\n" \
"Returns: [string] domain store path.\n" \
- " None if domid doesn't exist.\n" \
"Raises RuntimeError on error.\n" \
"\n"
if handler.store_mfn is None or handler.console_mfn is None:
raise XendError('Could not read store/console MFN')
+ dominfo.unpause()
+
dominfo.completeRestore(handler.store_mfn, handler.console_mfn)
return dominfo
vm = XendDomainInfo(xeninfo, domid, dompath, True)
except Exception, exn:
- if True:
+ if priv:
log.warn(str(exn))
vm = XendDomainInfo(xeninfo, domid, dompath, True)
try:
vm.construct()
vm.storeVmDetails()
+ vm.createDevices()
vm.createChannels()
+ vm.storeDomDetails()
return vm
except:
vm.destroy()
log.debug("domain_getinfo(%d) failed, ignoring: %s", dom, str(err))
return None
-class XendDomainInfo:
+class XendDomainInfo:
def __init__(self, info, domid = None, dompath = None, augment = False):
def completeRestore(self, store_mfn, console_mfn):
+ log.debug("XendDomainInfo.completeRestore")
+
self.store_mfn = store_mfn
self.console_mfn = console_mfn
self.introduceDomain()
- self.create_devices()
self.storeDomDetails()
- self.unpause()
self.refreshShutdown()
'memory/target': str(self.info['memory_KiB'])
}
- for (k, v) in self.info.items():
- if v:
- to_store[k] = str(v)
-
def f(n, v):
if v is not None:
to_store[n] = str(v)
raise VmError('Creating domain failed: name=%s' %
self.info['name'])
+ self.dompath = GetDomainPath(self.domid)
+
+ self.removeDom()
+
# Set maximum number of vcpus in domain
xc.domain_max_vcpus(self.domid, int(self.info['vcpus']))
assert self.store_port is not None
IntroduceDomain(self.domid, self.store_mfn, self.store_port)
- self.dompath = GetDomainPath(self.domid)
- assert self.dompath
def initDomain(self):
self.introduceDomain()
- self.create_devices()
+ self.createDevices()
self.info['start_time'] = time.time()
raise
- def create_configured_devices(self):
- for (n, c) in self.info['device']:
- self.createDevice(n, c)
-
+ ## public:
- def create_devices(self):
+ def createDevices(self):
"""Create the devices for a vm.
@raise: VmError for invalid devices
"""
- self.create_configured_devices()
+
+ for (n, c) in self.info['device']:
+ self.createDevice(n, c)
+
if self.image:
self.image.createDeviceModel()
- ## public:
-
def device_create(self, dev_config):
"""Create a new device.
case XS_SET_PERMS: return "SET_PERMS";
case XS_WATCH_EVENT: return "WATCH_EVENT";
case XS_ERROR: return "ERROR";
+ case XS_IS_DOMAIN_INTRODUCED: return "XS_IS_DOMAIN_INTRODUCED";
default:
return "**UNKNOWN**";
}
}
-void internal_rm(const char *name)
-{
- struct node *node = read_node(NULL, name);
- if (!node) {
- return;
- }
- _rm(NULL, node, name);
-}
-
-
static void do_get_perms(struct connection *conn, const char *name)
{
struct node *node;
do_introduce(conn, in);
break;
+ case XS_IS_DOMAIN_INTRODUCED:
+ do_is_domain_introduced(conn, onearg(in));
+ break;
+
case XS_RELEASE:
do_release(conn, onearg(in));
break;
struct connection *new_connection(connwritefn_t *write, connreadfn_t *read);
-void internal_rm(const char *name);
-
-
/* Is this a valid node name? */
bool is_valid_nodename(const char *node);
return ((intf->rsp_prod - intf->rsp_cons) != XENSTORE_RING_SIZE);
}
+static char *talloc_domain_path(void *context, unsigned int domid)
+{
+ return talloc_asprintf(context, "/local/domain/%u", domid);
+}
+
static struct domain *new_domain(void *context, unsigned int domid,
unsigned long mfn, int port)
{
domain->port = 0;
domain->shutdown = 0;
domain->domid = domid;
- domain->path = talloc_asprintf(domain, "/local/domain/%d", domid);
+ domain->path = talloc_domain_path(domain, domid);
domain->interface = xc_map_foreign_range(
*xc_handle, domain->domid,
getpagesize(), PROT_READ|PROT_WRITE, mfn);
list_add(&domain->list, &domains);
talloc_set_destructor(domain, destroy_domain);
- internal_rm(domain->path);
-
/* Tell kernel we're interested in this event. */
bind.remote_domain = domid;
bind.remote_port = port;
void do_get_domain_path(struct connection *conn, const char *domid_str)
{
- struct domain *domain;
- unsigned int domid;
+ char *path;
if (!domid_str) {
send_error(conn, EINVAL);
return;
}
+ path = talloc_domain_path(conn, atoi(domid_str));
+
+ send_reply(conn, XS_GET_DOMAIN_PATH, path, strlen(path) + 1);
+
+ talloc_free(path);
+}
+
+void do_is_domain_introduced(struct connection *conn, const char *domid_str)
+{
+ int result;
+ unsigned int domid;
+
+ if (!domid_str) {
+ send_error(conn, EINVAL);
+ return;
+ }
+
domid = atoi(domid_str);
if (domid == DOMID_SELF)
- domain = conn->domain;
+ result = 1;
else
- domain = find_domain_by_domid(domid);
+ result = (find_domain_by_domid(domid) != NULL);
- if (!domain)
- send_error(conn, ENOENT);
- else
- send_reply(conn, XS_GET_DOMAIN_PATH, domain->path,
- strlen(domain->path) + 1);
+ send_reply(conn, XS_IS_DOMAIN_INTRODUCED, result ? "T" : "F", 2);
}
static int close_xc_handle(void *_handle)
/* domid, mfn, eventchn, path */
void do_introduce(struct connection *conn, struct buffered_data *in);
+/* domid */
+void do_is_domain_introduced(struct connection *conn, const char *domid_str);
+
/* domid */
void do_release(struct connection *conn, const char *domid_str);
ARRAY_SIZE(iov), NULL));
}
-bool xs_release_domain(struct xs_handle *h, unsigned int domid)
+static void * single_with_domid(struct xs_handle *h,
+ enum xsd_sockmsg_type type,
+ unsigned int domid)
{
char domid_str[MAX_STRLEN(domid)];
sprintf(domid_str, "%u", domid);
- return xs_bool(xs_single(h, NULL, XS_RELEASE, domid_str, NULL));
+ return xs_single(h, NULL, type, domid_str, NULL);
+}
+
+bool xs_release_domain(struct xs_handle *h, unsigned int domid)
+{
+ return xs_bool(single_with_domid(h, XS_RELEASE, domid));
}
char *xs_get_domain_path(struct xs_handle *h, unsigned int domid)
return xs_single(h, NULL, XS_GET_DOMAIN_PATH, domid_str, NULL);
}
+bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid)
+{
+ return strcmp("F",
+ single_with_domid(h, XS_IS_DOMAIN_INTRODUCED, domid));
+}
+
/* Only useful for DEBUG versions */
char *xs_debug_command(struct xs_handle *h, const char *cmd,
void *data, unsigned int len)
*/
char *xs_get_domain_path(struct xs_handle *h, unsigned int domid);
+/* Return whether the domain specified has been introduced to xenstored.
+ */
+bool xs_is_domain_introduced(struct xs_handle *h, unsigned int domid);
+
/* Only useful for DEBUG versions */
char *xs_debug_command(struct xs_handle *h, const char *cmd,
void *data, unsigned int len);
XS_SET_PERMS,
XS_WATCH_EVENT,
XS_ERROR,
+ XS_IS_DOMAIN_INTRODUCED
};
#define XS_WRITE_NONE "NONE"